BI.namespace('background');

/**
 * 
 */
BI.background.ParalaxBackground = new Class({
    initialize: function (color) {
    	this.color = color;
    	this.elements = [];
    },
    addElement: function(element){
    	this.elements.push(element);
    },
    draw: function(context){
    	if (!!this.color){
    		context.drawContext.fillStyle = this.color;
    		context.drawContext.fillRect(0, 0, context.sceneDimension.width, context.sceneDimension.height);
    	}
    	
    	for (var i = 0; i < this.elements.length; i++){
    		var element = this.elements[i]; 
    		this.elements[i].draw(context);
    	}
    }
});

/**
 * 
 */
BI.background.ParalaxBackgroundElement = new Class({
    initialize : function (image, offsetX, offsetY) {
    	this.image = image;
    	this.offsetX = offsetX || 0;
    	this.offsetY = offsetY || 0;
    },
    draw: function(context){
    	var offsetX = this.offsetX - context.viewPort.left; 
    	var offsetY = this.offsetY - context.viewPort.top;
    	context.drawContext.drawImage(this.image, offsetX, offsetY);
    }
});